import request from 'umi-request';

export async function getCredentialList(params) {
  return request('/api/member/api-member/credential/member/getCredentialList', {
    method: 'post',
    data:{
      pageNum: params.current,
      pageSize: params.pageSize,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getUserInfo() {
  return request('/api/member/api-member/selfHelp/getEmployeeById', {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getCredentialItemList() {
  return request('/api/member/api-member/credential/getCredentialItemList', {
    method: 'POST',
  }).then((res) => {
    return res;
  });
}

export async function saveOrUpdateCredential(params) {
  return request('/api/member/api-member/credential/member/saveOrUpdateCredential', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res;
  });
}

export async function deleteCredentialById(id) {
  return request('/api/member/api-member/credential/member/deleteCredential', {
    method: 'delete',
    params: {
      id: id
    }
  }).then((res) => {
    return res;
  });
}

export async function saveOrDeleteHang(credentialId,type) {
  return request('/api/member/api-member/credential/member/saveOrDeleteHang', {
    method: 'POST',
    data: {
      credentialId:credentialId,
      type:type
    },
    requestType:'form'
  }).then((res) => {
    return res;
  });
}

export async function credentialBpm(id) {
  return request('/api/member/api-member/bpm/credentialBpm', {
    method: 'post',
    data: {id},
    requestType: 'form'
  }).then((res) => {
    return res;
  });
}
